<!doctype html>
<html lang="en">
<head>
    @include('web.layout.head')
    <link rel="stylesheet" href="{{mix('/css/web/user/contract.css')}}">
    <script src="{{mix('/js/web/frame/jedate/jquery.jedate.js')}}"></script>
    <link rel="stylesheet" href="{{mix('/js/web/frame/jedate/skin/jedate.css')}}">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

</head>
<body>

@include('web.layout.header')
@include('web.layout.user_tab')
<div class="base_member_content">
    <div class="w1200">
      @include('web.layout.seller_nav')
      <div class="nav_right flr">
            <div class="base_content">
                <div class="line_title">合同管理</div>
                <div class="content">
                    <div class="mrtop">
                        <span class="fl">添加编辑自定义销售合同</span>
                        <a href="/member/seller/contracts/create" class="fr">+ 添加合同</a>
                    </div>
                    <div class="table">
                        <table>
                            <thead>
                            <tr>
                                <th>合同名称</th>
                                {{--<th>合同编号</th>--}}
                                <th width="200">操作</th>
                                <th width="200"></th>
                            </tr>
                            </thead>
                            <tbody>
                            @foreach($list as $key=>$value)
                                <tr>
                                    <td>{{$value['name']}}</td>
                                    {{--<td>{{$value['contracts_code']?$value['contracts_code']:'-'}}</td>--}}
                                    <td>
                                      <a href="/member/seller/contracts/{{$value['id']}}/edit">编辑</a>
                                      <font>|</font>
                                      <a class="btn_del" data-id="{{$value['id']}}">删除</a>
                                    </td>
                                    <td>
                                        @if($value['is_default']==1)
                                        <span>默认合同</span>
                                        @else
                                        <a class="btn_default" data-id="{{$value['id']}}">设为默认</a>
                                        @endif
                                    </td>
                                </tr>
                            @endforeach
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="page">
                    @include('web.common.paginate')
                </div>
            </div>
        </div>
    </div>

</div>
@include('web.layout.footer')
<script type="text/javascript">
$(function(){
  //删除
  $('.btn_del').click(function(){
      var id = $(this).attr('data-id');
      layer.confirm('确认删除？', {
          btn: ['确认', '取消'] //可以无限个按钮
      }, function (index) {
          $.ajax({
              url: "{{URL::current()}}/"+id,
              type: 'delete',
              dataType: 'json',
              data: {'id': id},
              success: function (data) {
                  if (0 == data.code) {
                      layer.alert("删除成功", {
                          icon: 1
                      }, function () {
                          location.reload();
                      });
                  } else {
                      layer.alert(data.message, {
                          icon: 2
                      });
                  }
              }
          });
      }, function (index, layero) {
          layer.close(index);
      });
  });
  //设为默认
  $('.btn_default').click(function(){
      var id = $(this).attr('data-id');
      layer.confirm('确认设为为默认合同？', {
          btn: ['确认', '取消'] //可以无限个按钮
      }, function (index) {
          $.ajax({
              url: "{{URL::current()}}/set_default/"+id,
              type: 'post',
              dataType: 'json',
              data: {'id': id},
              success: function (data) {
                  if (0 == data.code) {
                      layer.alert("修改成功", {
                          icon: 1
                      }, function () {
                          location.reload();
                      });
                  } else {
                      layer.alert(data.message, {
                          icon: 2
                      });
                  }
              }
          });
      }, function (index, layero) {
          layer.close(index);
      });
  });
})
</script>
</body>
</html>